<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>bfpy.bfticks</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="bfpy-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://code.google.com/p/bfpy/">BfPy</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="bfpy-module.html">Package&nbsp;bfpy</a> ::
        Module&nbsp;bfticks
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="bfpy.bfticks-module.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== MODULE DESCRIPTION ==================== -->
<h1 class="epydoc">Module bfticks</h1><p class="nomargin-top"><span class="codelink"><a href="bfpy.bfticks-pysrc.html">source&nbsp;code</a></span></p>
<p>This module ease calculations of valid prices and next best prices at 
  a given distance or the closest next best price</p>

<!-- ==================== FUNCTIONS ==================== -->
<a name="section-Functions"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Functions</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Functions"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="GeneratePriceIncs"></a><span class="summary-sig-name">GeneratePriceIncs</span>()</span><br />
      Using <a href="bfpy.bfticks-module.html#priceRanges" 
      class="link">priceRanges</a> it generates a list containing every 
      possible valid price for Bf</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="bfpy.bfticks-pysrc.html#GeneratePriceIncs">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">float</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="bfpy.bfticks-module.html#GetPriceTicks" class="summary-sig-name">GetPriceTicks</a>(<span class="summary-sig-arg">price</span>,
        <span class="summary-sig-arg">ticks</span>,
        <span class="summary-sig-arg">betType</span>)</span><br />
      Returns the next price tick upwards/downwards for a given price and 
      bet type</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="bfpy.bfticks-pysrc.html#GetPriceTicks">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">float</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="bfpy.bfticks-module.html#GetClosestTick" class="summary-sig-name">GetClosestTick</a>(<span class="summary-sig-arg">price</span>,
        <span class="summary-sig-arg">down</span>)</span><br />
      Returns the next (and best) valid price upwards/downwards given a 
      price (which may or may not be valid) It is of course limited to 
      PriceMin/PriceMax</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="bfpy.bfticks-pysrc.html#GetClosestTick">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">float</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="bfpy.bfticks-module.html#GetClosestTickDown" class="summary-sig-name">GetClosestTickDown</a>(<span class="summary-sig-arg">price</span>)</span><br />
      Utility function to return the closest tick downwards</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="bfpy.bfticks-pysrc.html#GetClosestTickDown">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">float</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="bfpy.bfticks-module.html#GetClosestTickUp" class="summary-sig-name">GetClosestTickUp</a>(<span class="summary-sig-arg">price</span>)</span><br />
      Utility function to return the closest tick upwards</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="bfpy.bfticks-pysrc.html#GetClosestTickUp">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
</table>
<!-- ==================== VARIABLES ==================== -->
<a name="section-Variables"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Variables</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Variables"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">tuple of tuples</span>
    </td><td class="summary">
        <a href="bfpy.bfticks-module.html#priceRanges" class="summary-name">priceRanges</a> = <code title="((1.01, 2.0, 0.01),
 (2.0, 3.0, 0.02),
 (3.0, 4.0, 0.05),
 (4.0, 6.0, 0.1),
 (6.0, 10.0, 0.2),
 (10.0, 20.0, 0.5),
 (20.0, 30.0, 1.0),
 (30.0, 50.0, 2.0),
..."><code class="variable-group">(</code><code class="variable-group">(</code>1.01<code class="variable-op">, </code>2.0<code class="variable-op">, </code>0.01<code class="variable-group">)</code><code class="variable-op">, </code><code class="variable-group">(</code>2.0<code class="variable-op">, </code>3.0<code class="variable-op">, </code>0.02<code class="variable-group">)</code><code class="variable-op">, </code><code class="variable-group">(</code>3.0<code class="variable-op">, </code>4.0<code class="variable-op">,</code><code class="variable-ellipsis">...</code></code><br />
      valid price ranges and increments for bf
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">list</span>
    </td><td class="summary">
        <a href="bfpy.bfticks-module.html#PriceIncs" class="summary-name">PriceIncs</a> = <code title="[1.01,
 1.02,
 1.03,
 1.04,
 1.05,
 1.06,
 1.07,
 1.08,
..."><code class="variable-group">[</code>1.01<code class="variable-op">, </code>1.02<code class="variable-op">, </code>1.03<code class="variable-op">, </code>1.04<code class="variable-op">, </code>1.05<code class="variable-op">, </code>1.06<code class="variable-op">, </code>1.07<code class="variable-op">, </code>1.08<code class="variable-op">, </code>1<code class="variable-ellipsis">...</code></code><br />
      list of valid prices ordered
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">int</span>
    </td><td class="summary">
        <a name="PriceIncsLen"></a><span class="summary-name">PriceIncsLen</span> = <code title="350">350</code><br />
      number of valid prices
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">float</span>
    </td><td class="summary">
        <a name="PriceMin"></a><span class="summary-name">PriceMin</span> = <code title="1.01">1.01</code><br />
      Minimum valid price (1.01)
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">float</span>
    </td><td class="summary">
        <a name="PriceMax"></a><span class="summary-name">PriceMax</span> = <code title="1000.0">1000.0</code><br />
      Maximum valid price (1000.0)
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="__package__"></a><span class="summary-name">__package__</span> = <code title="'bfpy'"><code class="variable-quote">'</code><code class="variable-string">bfpy</code><code class="variable-quote">'</code></code>
    </td>
  </tr>
</table>
<!-- ==================== FUNCTION DETAILS ==================== -->
<a name="section-FunctionDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Function Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-FunctionDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="GetPriceTicks"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">GetPriceTicks</span>(<span class="sig-arg">price</span>,
        <span class="sig-arg">ticks</span>,
        <span class="sig-arg">betType</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="bfpy.bfticks-pysrc.html#GetPriceTicks">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Returns the next price tick upwards/downwards for a given price and 
  bet type</p>
  <p>Back bets increase price upwards Lay bets increase price downwards</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>price</code></strong> (float) - base price for next tick</li>
        <li><strong class="pname"><code>ticks</code></strong> (int) - number of ticks to move the price</li>
        <li><strong class="pname"><code>betType</code></strong> (B|L) - bet type (determines the direction)</li>
    </ul></dd>
    <dt>Returns: float</dt>
        <dd>the passed prices decreased x ticks</dd>
  </dl>
</td></tr></table>
</div>
<a name="GetClosestTick"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">GetClosestTick</span>(<span class="sig-arg">price</span>,
        <span class="sig-arg">down</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="bfpy.bfticks-pysrc.html#GetClosestTick">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Returns the next (and best) valid price upwards/downwards given a 
  price (which may or may not be valid) It is of course limited to 
  PriceMin/PriceMax</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>price</code></strong> (float) - base price for next price</li>
        <li><strong class="pname"><code>down</code></strong> (bool) - go downwards (back bets) if True, else go upwards (lay bets)</li>
    </ul></dd>
    <dt>Returns: float</dt>
        <dd>the best price upwards/downwards</dd>
  </dl>
</td></tr></table>
</div>
<a name="GetClosestTickDown"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">GetClosestTickDown</span>(<span class="sig-arg">price</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="bfpy.bfticks-pysrc.html#GetClosestTickDown">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Utility function to return the closest tick downwards</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>price</code></strong> (float) - base price for next price</li>
    </ul></dd>
    <dt>Returns: float</dt>
        <dd>the best price downwards</dd>
  </dl>
</td></tr></table>
</div>
<a name="GetClosestTickUp"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">GetClosestTickUp</span>(<span class="sig-arg">price</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="bfpy.bfticks-pysrc.html#GetClosestTickUp">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Utility function to return the closest tick upwards</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>price</code></strong> (float) - base price for next price</li>
    </ul></dd>
    <dt>Returns: float</dt>
        <dd>the best price upwards</dd>
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== VARIABLES DETAILS ==================== -->
<a name="section-VariablesDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Variables Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-VariablesDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="priceRanges"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <h3 class="epydoc">priceRanges</h3>
  valid price ranges and increments for bf
  <dl class="fields">
    <dt>Type:</dt>
      <dd>tuple of tuples</dd>
  </dl>
  <dl class="fields">
    <dt>Value:</dt>
      <dd><table><tr><td><pre class="variable">
<code class="variable-group">(</code><code class="variable-group">(</code>1.01<code class="variable-op">, </code>2.0<code class="variable-op">, </code>0.01<code class="variable-group">)</code><code class="variable-op">,</code>
 <code class="variable-group">(</code>2.0<code class="variable-op">, </code>3.0<code class="variable-op">, </code>0.02<code class="variable-group">)</code><code class="variable-op">,</code>
 <code class="variable-group">(</code>3.0<code class="variable-op">, </code>4.0<code class="variable-op">, </code>0.05<code class="variable-group">)</code><code class="variable-op">,</code>
 <code class="variable-group">(</code>4.0<code class="variable-op">, </code>6.0<code class="variable-op">, </code>0.1<code class="variable-group">)</code><code class="variable-op">,</code>
 <code class="variable-group">(</code>6.0<code class="variable-op">, </code>10.0<code class="variable-op">, </code>0.2<code class="variable-group">)</code><code class="variable-op">,</code>
 <code class="variable-group">(</code>10.0<code class="variable-op">, </code>20.0<code class="variable-op">, </code>0.5<code class="variable-group">)</code><code class="variable-op">,</code>
 <code class="variable-group">(</code>20.0<code class="variable-op">, </code>30.0<code class="variable-op">, </code>1.0<code class="variable-group">)</code><code class="variable-op">,</code>
 <code class="variable-group">(</code>30.0<code class="variable-op">, </code>50.0<code class="variable-op">, </code>2.0<code class="variable-group">)</code><code class="variable-op">,</code>
<code class="variable-ellipsis">...</code>
</pre></td></tr></table>
</dd>
  </dl>
</td></tr></table>
</div>
<a name="PriceIncs"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <h3 class="epydoc">PriceIncs</h3>
  list of valid prices ordered
  <dl class="fields">
    <dt>Type:</dt>
      <dd>list</dd>
  </dl>
  <dl class="fields">
    <dt>Value:</dt>
      <dd><table><tr><td><pre class="variable">
<code class="variable-group">[</code>1.01<code class="variable-op">,</code>
 1.02<code class="variable-op">,</code>
 1.03<code class="variable-op">,</code>
 1.04<code class="variable-op">,</code>
 1.05<code class="variable-op">,</code>
 1.06<code class="variable-op">,</code>
 1.07<code class="variable-op">,</code>
 1.08<code class="variable-op">,</code>
<code class="variable-ellipsis">...</code>
</pre></td></tr></table>
</dd>
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="bfpy-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://code.google.com/p/bfpy/">BfPy</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Sat Jun 04 02:13:34 2011
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
